package com.summer.framework.admin.controller.rpc;

import com.summer.framework.common.controller.BaseRpcController;
import com.summer.framework.common.entity.Users;
import com.summer.framework.admin.service.UserService;
import com.summer.framework.common.entity.response.BooleanResponse;
import com.summer.framework.common.exception.admin.UserNameNotFoundException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @auther: 杨杰
 * @date: 2018/12/25 10:29
 * @description:
 */
@RestController
@RequestMapping("/api/user")
@Slf4j
public class UserRpcController extends BaseRpcController<UserService, Users> {

    @GetMapping("/getUserByName/{userName}")
    public Users user(@PathVariable String userName) throws UserNameNotFoundException {
        return baseService.getUserByName(userName);
    }


    @PostMapping()
    protected BooleanResponse save(@RequestBody Users t) {
        log.info("RPC save");
        return new BooleanResponse("", baseService.save(t));
    }


}